//
//  CancelTaskFooterView.m
//  YuTang
//
//  Created by 葛悦彣 on 2024/8/20.
//

#import "CancelTaskFooterView.h"
#import "VoiceView.h"

@interface CancelTaskFooterView ()
@property (nonatomic ,strong)  VoiceView * voice;
@end

@implementation CancelTaskFooterView


+ (instancetype)NewView {
    CancelTaskFooterView * view = [CancelTaskFooterView new];
    view.clipsToBounds = YES;
    view.backgroundColor = UIColor.whiteColor;
    [view newUI];
    return view;
}
- (void)newUI{
    MJWeakSelf
    VoiceView * voice = [VoiceView NewView];
    voice.removeBlock = ^{
        weakSelf.model.voiceUrl = @"";
        weakSelf.model.voiceDuration = @"";
        if(weakSelf.VoiceBlock){
            weakSelf.VoiceBlock(@"");
        };
    };
    voice.backgroundColor = KcolorHex(@"#F6F7F9");
    [DTKTool YJ:kwt(5) andView:voice];
    self.voice = voice;
    voice.SoundAndTimeBlock = ^(NSString * _Nonnull Url, NSString * _Nonnull previewUrl, NSString * _Nonnull voiceDuration) {
        weakSelf.model.TJvoiceUrl = Url;
        weakSelf.model.voiceUrl = previewUrl;
        weakSelf.voice.voiceUrl = previewUrl;
        weakSelf.voice.voiceDuration = voiceDuration;
    };
    [self addSubview:voice];
    [voice mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(kwt(5));
        make.left.offset(kwt(12));
        make.right.offset(kwt(-12));
        make.height.offset(kwt(53));

    }];
    
}
-(void)setModel:(CancelAndTransferModel *)model{
    _model = model;
    MJWeakSelf;
    model.openDurationBlock = ^(NSString * _Nonnull voiceDuration) {
        weakSelf.voice.voiceDuration = voiceDuration;
    };
    self.voice.voiceUrl = model.voiceUrl;
    self.voice.voiceDuration = model.voiceDuration;
}
@end
